<%--
/*******************************************************************************
* Contributors: Topcased contributors and others - initial API and implementation
* Authors : Alexandru Burdusel
********************************************************************************/
--%>

<%-----------------------------------Section Import---------------------------------%>
<%
metamodel http://www.eclipse.org/uml2/3.0.0/UML
import org.topcased.uml2qos.services.Uml2Services
import org.topcased.uml2qos.services.PhpServices
import org.topcased.uml2qos.services.StringServices
import org.topcased.uml2qos.services.CommentServices
import org.topcased.uml2qos.services.AttServices
import org.topcased.uml2qos.utilities.Configuration
import org.topcased.uml2qos.services.UmlQosServices
import org.topcased.uml2qos.templates.common
%>
<%-------------------------------------Aspect pointcuts-------------------------------------%>
<%script type="Package" name="fullPath"%>
classes/<%for (ancestor()){%><%name.nPush()%><%}%><%for (ancestor()){%><%if (nPeek().length() > 1){%><%nPeek()%>/<%}%><%nPop()%><%}%>
<%script type="Class" name="fileFullPath"%>
<%if (ownedOperation && ownedOperation.name.hasPreArguments()) {%> 
<%if (checkClass){%>
<%package.fullPath%>/<%name%>.pointcut.definition.php
<%}%>
<%}%>
<%script type="Operation" name="genAspectCutOperation" post="indentTab()"%>
public function cut_<%name.removePreArguments%>()
<%script type="Operation" name="genAspectCutOperationBody" post="indentTab()"%>
<%if (!isAbstract) {%>
{
<%addTab%>//Start pointcut definition for <%name.removeSpaces()%>()
<%-- Return type for functions with return value --%> 
<%addTab%>return array('cp' => '<%parent.name%>',
<%addTab%><%addTab%><%addTab%><%addTab%>'mp' => '<%name.removePreArguments()%>',
<%addTab%><%addTab%><%addTab%><%addTab%>'am' => array('before' => 'before_<%name.removePreArguments()%>'));
<%addTab%>//End point cut definition for <%name.removeSpaces()%>
}
<%}%>
<%script type="Operation" name="genAdviceDefinition" post="indentTab()"%>
public function before_<%name.removePreArguments()%>() {
<%name.generateQosCode()%>
}
<%script type="Class" name="genAspectCutMethod"%>
<%if (ownedOperation && ownedOperation.name.hasPreArguments() && !isAbstract) {%> 
<%addTab%>//Methods<%name.nPush()%>
	<%for (ownedOperation) {%>
		<%if (name.hasPreArguments()){%>
<%pointcutDoc%>
<%genAspectCutOperation%>
<%genAspectCutOperationBody%>
<%adviceDoc%>
<%genAdviceDefinition%>
		<%}%>
	<%}%>
<%}%>
<%script type="Class" name="genAspectProto"%>
<%if (isDocNeeded){%>
/**
 *  Class <%name%>_pointcuts
 *  Pointcuts defined in this class will be applied to the
 *  methods in the <%name%> class.
 */
<%}%>
<%if (isClass){%>
class <%name%>_pointcuts #the suffix _pointcuts is mandatory
		extends aop_pointcut_definition {
<%}%>
<%script type="Class" name="default" file="<%fileFullPath%>"%>
<?php
<%generateHeader%>
<%genAspectProto%>
<%genAspectCutMethod%>
}

//EOF <%package.fullPath%><%name%>.pointcut.php
?>